﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

using Pg.BioMedics.SDR.Entities;
using Pg.BioMedics.SDR.Entities.Codes;

namespace Pg.BioMedics.SDR.Services
{
    /// <summary>
    /// An interface for service holding logic related 
    /// with documents indexing routines
    /// </summary>
    [ServiceContract]
    public interface IIndexingService : IService
    {
        /// <summary>
        /// Registers a new document in the system. This method will 
        /// initialize indexing flow for the given document
        /// </summary>
        /// <param name="document">A new document</param>
        /// <param name="content">Document content</param>
        /// <param name="author">document's author</param>
        /// <returns>Registered document</returns>
        [OperationContract]
        Document RegisterDocument(Document document, Content content, Person author);

        /// <summary>
        /// Registers a new document in the system. This method will instantiate all 
        /// required entities and initialize indexing flow.
        /// </summary>
        /// <param name="title">Document title</param>
        /// <param name="description">Document description</param>
        /// <param name="fileName">File name</param>
        /// <param name="fileLocation">Temporary file location</param>
        /// <param name="authorLogin">Document author login</param>
        /// <returns>Registered document</returns>
        [OperationContract]
        Document RegisterDocument(string title, string description, string fileName, string fileLocation, string authorLogin);

        /// <summary>
        /// Gets list of documents authored by the given person
        /// </summary>
        /// <param name="author">Document author</param>
        /// <returns>List of documents</returns>
        [OperationContract]
        IList<Document> GetDocuments(Person author);

        /// <summary>
        /// Gets list of documents authored by the given person
        /// </summary>
        /// <param name="authorLogin">Document author</param>
        /// <returns>List of documents</returns>
        [OperationContract]
        IList<Document> GetDocuments(string authorLogin);

        /// <summary>
        /// Gets list of pending documents authored by the given person
        /// </summary>
        /// <param name="author">Document author</param>
        /// <returns>List of documents</returns>
        [OperationContract]
        IList<Document> GetPendingDocuments(Person author);

        /// <summary>
        /// Gets list of pending documents authored by the given person
        /// </summary>
        /// <param name="authorLogin">Document author login</param>
        /// <returns>List of documents</returns>
        [OperationContract]
        IList<Document> GetPendingDocuments(string authorLogin);

        /// <summary>
        /// Removes given document from the list of available documents
        /// </summary>
        /// <param name="document">Document instance</param>
        /// <param name="author">Person removing document</param>
        [OperationContract]
        void RemoveDocument(Document document, Person author);

        /// <summary>
        /// Registers a new annotation for given document. This method is executed 
        /// each time new annotation is being attached to the document.
        /// </summary>
        /// <param name="document">Document which will be annotated</param>
        /// <param name="content">Annotation audio content. Must be wav</param>
        /// <param name="author">Annotation author</param>
        /// <returns>Registered annotation</returns>
        [OperationContract]
        Annotation RegisterAnnotation(Document document, Content content, Person author);

        /// <summary>
        /// Registers a new annotation for the given document. This method is executed 
        /// each time a new annotation is being attached to the document.
        /// </summary>
        /// <param name="document">Document which will be annotated</param>
        /// <param name="fileName">Annotation file name</param>
        /// <param name="fileLocation">Annotation file location</param>
        /// <param name="authorLogin">Annotation author login</param>
        /// <returns>Registered annotation</returns>
        [OperationContract]
        Annotation RegisterAnnotation(Document document, string fileName, string fileLocation, string authorLogin);

        /// <summary>
        /// Gets list of annotations assigned to the given document
        /// </summary>
        /// <param name="document">Existing document</param>
        /// <returns>List of annotations assigned to the given document</returns>
        [OperationContract]
        IList<Annotation> GetAnnotations(Document document);

        /// <summary>
        /// Gets content of the given document
        /// </summary>
        /// <param name="document">Document instance</param>
        /// <returns>Document content or null if document doesnot exist</returns>
        [OperationContract]
        Content GetContent(Document document);
    }
}
